package creationPattern.Factory.Factory_03.controller;

import creationPattern.Factory.Factory_02.entity.AwardInfo;
import creationPattern.Factory.Factory_02.entity.ResponseResult;
import creationPattern.Factory.Factory_02.service.IFreeGoods;
import creationPattern.Factory.Factory_03.factory.FreeGoodsFactoryMap;
import creationPattern.Factory.Factory_03.factory.impl.DiscountFactory;
import creationPattern.Factory.Factory_03.factory.FreeGoodsFactory;
import creationPattern.Factory.Factory_03.factory.impl.SmallGiftFactory;

/**
 * 发放奖品接口
 */
public class Controller {
    public ResponseResult awardToUser(AwardInfo awardInfo){
        FreeGoodsFactory factory =
                FreeGoodsFactoryMap.getParserFactory(awardInfo.getAwardType());

        System.out.println("================工厂方法模式重构");
        // 通过具体工厂的实例，创建具体产品的实例
        IFreeGoods instance = factory.getInstance();
        // 通过具体产品的实例，执行代码
        return instance.sendFreeGoods(awardInfo);
    }
}
